/**
 * @Author：ming
 * @Date：2023/9/26 11:27 AM
 * @Filename：Lc383
 */

import java.util.ArrayList;

/**
 * @author ming
 */
public class Lc383 {
    public boolean canConstruct(String ransomNote, String magazine) {
        char[] cma = magazine.toCharArray();
        ArrayList<Character> lma = new ArrayList<>();
        for (char c : cma) {
            lma.add(c);
        }

        char[] rma = ransomNote.toCharArray();
        ArrayList<Character> lra = new ArrayList<>();
        for (char c : rma) {
            lra.add(c);
        }

        for (Character c : lra) {
            if(lma.contains(c)){
                int i = lma.indexOf(c);
                lma.remove(i);
            }else {
                return false;
            }
        }

        return true;

    }
}
